package com.zmn.plat.services.impl.online.service.group.product.group;

import com.zmn.plat.model.entity.online.service.group.product.group.OnlineServiceGroupProductGroup;
import com.zmn.plat.model.entity.online.service.group.product.group.OnlineServiceGroupProductGroupQuery;
import com.zmn.plat.persistence.interfaces.online.service.group.product.group.OnlineServiceGroupProductGroupDao;
import com.zmn.plat.services.interfaces.online.service.group.product.group.OnlineServiceGroupProductGroupService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.util.List;


@Service
@Slf4j
public class OnlineServiceGroupProductGroupServiceImpl implements OnlineServiceGroupProductGroupService {

    @Resource
    OnlineServiceGroupProductGroupDao onlineServiceGroupProductGroupDao;

    @Override
    public OnlineServiceGroupProductGroup findByKey(Integer relateId) {
        return onlineServiceGroupProductGroupDao.findByKey(relateId);
    }

    @Override
    public List<OnlineServiceGroupProductGroup> listPageByQuery(OnlineServiceGroupProductGroupQuery query) {
        int count = countByQuery(query);
        query.setTotalCount(count);
        return onlineServiceGroupProductGroupDao.listPageByQuery(query);
    }

    @Override
    public List<OnlineServiceGroupProductGroup> listByQuery(OnlineServiceGroupProductGroupQuery query) {
        return onlineServiceGroupProductGroupDao.listByQuery(query);
    }

    @Override
    public List<OnlineServiceGroupProductGroup> listAll() {
        return onlineServiceGroupProductGroupDao.listAll();
    }

    @Override
    public Integer countByQuery(OnlineServiceGroupProductGroupQuery query) {
        return onlineServiceGroupProductGroupDao.countByQuery(query);
    }
    @Override
    public Integer updateByKey(OnlineServiceGroupProductGroup onlineServiceGroupProductGroup) {
        return onlineServiceGroupProductGroupDao.updateByKey(onlineServiceGroupProductGroup);
    }

    @Override
    public Integer insert(OnlineServiceGroupProductGroup onlineServiceGroupProductGroup) {
        return onlineServiceGroupProductGroupDao.insert(onlineServiceGroupProductGroup);
    }

    @Override
    public Integer insertBatch(List<OnlineServiceGroupProductGroup> list) {
        if (CollectionUtils.isEmpty(list)) {
            log.error("在线客服分组产品组配置新增数据,list为null");
            return null;
        }

        return onlineServiceGroupProductGroupDao.insertBatch(list);
    }

    @Override
    public Integer deleteByGroupIdAndBizType(Integer groupId, Integer bizType) {
        return onlineServiceGroupProductGroupDao.deleteByGroupIdAndBizType(groupId, bizType);
    }

    @Override
    public Integer deleteByKey(Integer relateId) {
        return onlineServiceGroupProductGroupDao.deleteByKey(relateId);
    }

}